package logical_spaces.DAO;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.*;

/**
 *
 * @author juan
 */

public class TableSpaceDAO {
    
    public static Connection conn;

    public TableSpaceDAO(Connection conn) {
        TableSpaceDAO.conn = conn;
    }
    
    public ResultSet executeStatement( String sql ) throws SQLException {
        
//        System.out.println( sql );
        Statement statement = conn.createStatement();
        ResultSet resultSet = statement.executeQuery( sql );
        return resultSet;
        
    }
    
    public String eliminarTablespace(String statement) throws SQLException {

        Statement stmt = conn.createStatement();
        try {
            stmt.executeQuery(statement);
            stmt.close();
            return "Tablespace eliminado exitosamente";

        } catch (Exception e) {
            System.out.println(e.getMessage());
            return e.getMessage();
        }
        
    }
    
    public String modificarTablespace(String statement) throws SQLException {

        Statement stmt = conn.createStatement();
        try {
            stmt.executeQuery(statement);
            stmt.close();
            return "Tablespace modificado exitosamente";

        } catch (Exception e) {
            System.out.println(e.getMessage());
            return e.getMessage();
        }
        
    }

    public String modificarTablespaceDropDataFile(String statement) throws SQLException {

        Statement stmt = conn.createStatement();
        try {
            stmt.executeQuery(statement);
            stmt.close();
            return "DataFile eliminado exitosamente";

        } catch (Exception e) {
            System.out.println(e.getMessage());
            return e.getMessage();
        }
        
    }

    
    
    public String createTableSpace(String statement) throws SQLException {

        Statement stmt = conn.createStatement();
        try {
            stmt.executeQuery(statement);
            stmt.close();
            return "Tablespace creado satisfactoriamente.";

        } catch (Exception e) {
            System.out.println(e.getMessage());
            return e.getMessage();
        }
        
        
    }
    
    
    
}
